home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / jabber1a / frmjabbe.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-05  |  17.9 KB  |  569 lines

  1. VERSION 5.00
  2. Begin VB.Form FrmJabber 
  3.    Caption         =   "JabberWock"
  4.    ClientHeight    =   6015
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6030
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   6015
  10.    ScaleWidth      =   6030
  11.    StartUpPosition =   2  'CenterScreen
  12.    Begin VB.CommandButton CmdInst 
  13.       Caption         =   "Help"
  14.       Height          =   375
  15.       Left            =   4920
  16.       TabIndex        =   34
  17.       Top             =   4920
  18.       Width           =   1095
  19.    End
  20.    Begin VB.CommandButton CmdSN 
  21.       Caption         =   "Save Names"
  22.       Height          =   375
  23.       Left            =   4920
  24.       TabIndex        =   18
  25.       Top             =   5280
  26.       Width           =   1095
  27.    End
  28.    Begin VB.CommandButton CmdExit 
  29.       Caption         =   "Exit"
  30.       Height          =   375
  31.       Left            =   4920
  32.       TabIndex        =   19
  33.       Top             =   5640
  34.       Width           =   1095
  35.    End
  36.    Begin VB.CommandButton CmdAbt 
  37.       Caption         =   "About"
  38.       Height          =   375
  39.       Left            =   4920
  40.       TabIndex        =   17
  41.       Top             =   4560
  42.       Width           =   1095
  43.    End
  44.    Begin VB.Frame Frame3 
  45.       Caption         =   "Word Options"
  46.       Height          =   1455
  47.       Left            =   0
  48.       TabIndex        =   26
  49.       Top             =   4560
  50.       Width           =   4815
  51.       Begin VB.OptionButton OptFirst 
  52.          Caption         =   "Start Randomly"
  53.          Height          =   255
  54.          Index           =   0
  55.          Left            =   2880
  56.          TabIndex        =   35
  57.          Top             =   600
  58.          Width           =   1815
  59.       End
  60.       Begin VB.CommandButton CmdOptions 
  61.          Caption         =   "Save Options"
  62.          Height          =   255
  63.          Left            =   2880
  64.          TabIndex        =   11
  65.          Top             =   240
  66.          Width           =   1455
  67.       End
  68.       Begin VB.TextBox TxtMin 
  69.          Height          =   285
  70.          Left            =   120
  71.          TabIndex        =   7
  72.          Top             =   480
  73.          Width           =   375
  74.       End
  75.       Begin VB.TextBox TxtMax 
  76.          Height          =   285
  77.          Left            =   120
  78.          TabIndex        =   8
  79.          Top             =   1080
  80.          Width           =   375
  81.       End
  82.       Begin VB.OptionButton OptFirst 
  83.          Caption         =   "Start With Consonant"
  84.          Height          =   255
  85.          Index           =   1
  86.          Left            =   2880
  87.          TabIndex        =   12
  88.          Top             =   840
  89.          Value           =   -1  'True
  90.          Width           =   1815
  91.       End
  92.       Begin VB.OptionButton OptFirst 
  93.          Caption         =   "Start With Vowel"
  94.          Height          =   255
  95.          Index           =   2
  96.          Left            =   2880
  97.          TabIndex        =   13
  98.          Top             =   1080
  99.          Width           =   1695
  100.       End
  101.       Begin VB.TextBox TxtStart 
  102.          Height          =   285
  103.          Left            =   1560
  104.          MaxLength       =   10
  105.          TabIndex        =   9
  106.          Top             =   480
  107.          Width           =   1215
  108.       End
  109.       Begin VB.TextBox TxtEnd 
  110.          Height          =   285
  111.          Left            =   1560
  112.          MaxLength       =   10
  113.          TabIndex        =   10
  114.          Top             =   1080
  115.          Width           =   1215
  116.       End
  117.       Begin VB.Label Label1 
  118.          Caption         =   "Min word Length:"
  119.          Height          =   255
  120.          Left            =   120
  121.          TabIndex        =   30
  122.          Top             =   240
  123.          Width           =   1335
  124.       End
  125.       Begin VB.Label Label2 
  126.          Caption         =   "Max word Length:"
  127.          Height          =   255
  128.          Left            =   120
  129.          TabIndex        =   29
  130.          Top             =   840
  131.          Width           =   1335
  132.       End
  133.       Begin VB.Label Label3 
  134.          Caption         =   "Starting Letter(s)"
  135.          Height          =   255
  136.          Left            =   1560
  137.          TabIndex        =   28
  138.          Top             =   240
  139.          Width           =   1335
  140.       End
  141.       Begin VB.Label Label4 
  142.          Caption         =   "Ending Letter(s)"
  143.          Height          =   255
  144.          Left            =   1560
  145.          TabIndex        =   27
  146.          Top             =   840
  147.          Width           =   1335
  148.       End
  149.    End
  150.    Begin VB.Frame Frame2 
  151.       Caption         =   "Letters File"
  152.       Height          =   1215
  153.       Left            =   3120
  154.       TabIndex        =   23
  155.       Top             =   3240
  156.       Width           =   2895
  157.       Begin VB.CommandButton CmdNew 
  158.          Caption         =   "New"
  159.          Height          =   255
  160.          Left            =   120
  161.          TabIndex        =   14
  162.          Top             =   840
  163.          Width           =   735
  164.       End
  165.       Begin VB.CommandButton CmdSave 
  166.          Caption         =   "Save"
  167.          Height          =   255
  168.          Left            =   2040
  169.          TabIndex        =   16
  170.          Top             =   840
  171.          Width           =   735
  172.       End
  173.       Begin VB.TextBox TxtFileName 
  174.          BackColor       =   &H00C0C0C0&
  175.          Height          =   285
  176.          Left            =   120
  177.          Locked          =   -1  'True
  178.          MaxLength       =   100
  179.          TabIndex        =   24
  180.          Top             =   480
  181.          Width           =   2655
  182.       End
  183.       Begin VB.CommandButton CmdOpen 
  184.          Caption         =   "Open"
  185.          Height          =   255
  186.          Left            =   1080
  187.          TabIndex        =   15
  188.          Top             =   840
  189.          Width           =   735
  190.       End
  191.       Begin VB.Label Label5 
  192.          Caption         =   "File name:"
  193.          Height          =   255
  194.          Left            =   120
  195.          TabIndex        =   25
  196.          Top             =   240
  197.          Width           =   2655
  198.       End
  199.    End
  200.    Begin VB.Frame Frame1 
  201.       Caption         =   "Add/Remove/Generate"
  202.       Height          =   1215
  203.       Left            =   0
  204.       TabIndex        =   22
  205.       Top             =   3240
  206.       Width           =   3015
  207.       Begin VB.CommandButton CmdClear 
  208.          Caption         =   "Clear Names"
  209.          Height          =   255
  210.          Left            =   1680
  211.          TabIndex        =   6
  212.          Top             =   720
  213.          Width           =   1215
  214.       End
  215.       Begin VB.OptionButton OptCV 
  216.          Caption         =   "Vowel"
  217.          Height          =   255
  218.          Index           =   1
  219.          Left            =   120
  220.          TabIndex        =   3
  221.          Top             =   840
  222.          Width           =   1215
  223.       End
  224.       Begin VB.OptionButton OptCV 
  225.          Caption         =   "Consonant"
  226.          Height          =   255
  227.          Index           =   0
  228.          Left            =   120
  229.          TabIndex        =   2
  230.          Top             =   600
  231.          Value           =   -1  'True
  232.          Width           =   1215
  233.       End
  234.       Begin VB.CommandButton CmdAdd 
  235.          Caption         =   "Add"
  236.          Height          =   255
  237.          Left            =   1680
  238.          TabIndex        =   4
  239.          Top             =   240
  240.          Width           =   1215
  241.       End
  242.       Begin VB.TextBox TxtAR 
  243.          Height          =   285
  244.          Left            =   120
  245.          TabIndex        =   1
  246.          Top             =   240
  247.          Width           =   1215
  248.       End
  249.       Begin VB.CommandButton CmdGen 
  250.          Caption         =   "Make Names"
  251.          Height          =   255
  252.          Left            =   1680
  253.          TabIndex        =   5
  254.          Top             =   480
  255.          Width           =   1215
  256.       End
  257.    End
  258.    Begin VB.ListBox LstNam 
  259.       Height          =   2985
  260.       ItemData        =   "FrmJabber.frx":0000
  261.       Left            =   4080
  262.       List            =   "FrmJabber.frx":0002
  263.       TabIndex        =   21
  264.       TabStop         =   0   'False
  265.       ToolTipText     =   "Double click to remove items"
  266.       Top             =   240
  267.       Width           =   1935
  268.    End
  269.    Begin VB.ListBox LstVow 
  270.       Height          =   2985
  271.       ItemData        =   "FrmJabber.frx":0004
  272.       Left            =   2040
  273.       List            =   "FrmJabber.frx":0006
  274.       TabIndex        =   20
  275.       TabStop         =   0   'False
  276.       ToolTipText     =   "Double click to remove items"
  277.       Top             =   240
  278.       Width           =   1935
  279.    End
  280.    Begin VB.ListBox LstCon 
  281.       Height          =   2985
  282.       ItemData        =   "FrmJabber.frx":0008
  283.       Left            =   0
  284.       List            =   "FrmJabber.frx":000A
  285.       TabIndex        =   0
  286.       TabStop         =   0   'False
  287.       ToolTipText     =   "Double click to remove items"
  288.       Top             =   240
  289.       Width           =   1935
  290.    End
  291.    Begin VB.Label Label8 
  292.       Alignment       =   2  'Center
  293.       Caption         =   "Generated Names"
  294.       Height          =   255
  295.       Left            =   4080
  296.       TabIndex        =   33
  297.       Top             =   0
  298.       Width           =   1935
  299.    End
  300.    Begin VB.Label Label7 
  301.       Alignment       =   2  'Center
  302.       Caption         =   "Vowels"
  303.       Height          =   255
  304.       Left            =   2040
  305.       TabIndex        =   32
  306.       Top             =   0
  307.       Width           =   1935
  308.    End
  309.    Begin VB.Label Label6 
  310.       Alignment       =   2  'Center
  311.       Caption         =   "Consonants"
  312.       Height          =   255
  313.       Left            =   0
  314.       TabIndex        =   31
  315.       Top             =   0
  316.       Width           =   1935
  317.    End
  318. Attribute VB_Name = "FrmJabber"
  319. Attribute VB_GlobalNameSpace = False
  320. Attribute VB_Creatable = False
  321. Attribute VB_PredeclaredId = True
  322. Attribute VB_Exposed = False
  323. Private Const OptFile As String = "\option.dat"
  324. Dim OptionFile As String, OptLen As Integer, DefaultPath As String, Dirty As Boolean, LetterFile As String
  325. Private Sub CmdAdd_Click() 'Add contents of textbox to the listbox
  326. TxtAR.SetFocus
  327. ' If the textbox is empty, exit
  328. If TxtAR.Text = "" Then
  329.     Beep
  330.     Exit Sub
  331. End If
  332. ' Check to see which one to add it to
  333. If OptCV(0).Value = True Then
  334.     LstCon.AddItem TxtAR.Text
  335.     LstVow.AddItem TxtAR.Text
  336. End If
  337. ' Clear the textbox
  338. TxtAR.Text = ""
  339. ' List has changed, it's "Dirty"
  340. Dirty = True
  341. End Sub
  342. Private Sub CmdClear_Click()
  343. ' Clears name list
  344. LstNam.Clear
  345. End Sub
  346. Private Sub CmdGen_Click()
  347. Dim Words As String, WPast As String, WordLen As Integer
  348. Dim RI As Integer, X As Integer
  349. Dim L As Integer, LPast As Integer
  350. For X = 1 To 100
  351.     Words = "" ' Clear word
  352.     ' Get random word length
  353.     WordLen = GRI(Val(TxtMin.Text), Val(TxtMax.Text))
  354.     ' Decide whether consonant, vowel, or random
  355.     Select Case Trim(Opt.First)
  356.         Case Is = 1
  357.             L = 2
  358.         Case Is = 2
  359.             L = 1
  360.         Case Else
  361.             L = GRI(1, 2)
  362.     End Select
  363.     ' Do until the length is correct
  364.     Do
  365.         LPast = L ' Rember whether last was consonant or vowel
  366.         L = L + 1 ' Change to other
  367.         If L = 3 Then L = 1 ' 3 is out of bounds, change to 1
  368.         ' Pick consonant if 1, vowel if 2
  369.         If L = 1 Then RI = GRI(0, LstCon.ListCount - 1): Words = Words + LstCon.List(RI)
  370.         If L = 2 Then RI = GRI(0, LstVow.ListCount - 1): Words = Words + LstVow.List(RI)
  371.         
  372.         ' If word is too long, reset everything
  373.         If Len(Words) > WordLen Then: Words = WPast: L = LPast
  374.         WPast = Words ' Remembers words
  375.     Loop Until Len(Words) = WordLen
  376.     ' Add first and last parts to word
  377.     If TxtStart.Text <> "" Then Words = TxtStart.Text + Words
  378.     If TxtEnd.Text <> "" Then Words = Words + TxtEnd.Text
  379.     ' Convert word to propper case
  380.     Words = StrConv(Words, vbProperCase)
  381.     ' Add name to list
  382.     LstNam.AddItem Words
  383. End Sub
  384. Private Sub CmdAbt_Click() ' About this program
  385. MsgBox "JabberWin 1.0" & vbNewLine & vbNewLine & _
  386.         "Based upon Jaberwock for DOS:" & "(c)opyright 1998 by Steven Duggar (saturnswingr@geocities.com)" & vbNewLine & vbNewLine & _
  387.         "Original VB code: (c)opyright 1999 by Phillip Riley (phillip@softhome.net)" & vbNewLine & vbNewLine & _
  388.         "100% compatable with datafiles and alphabets from the original JabberWin.", _
  389.         vbInformation, "About this Program"
  390.         
  391. End Sub
  392. Private Sub CmdExit_Click()
  393. If Dirty Then
  394.     Resp = MsgBox("Do you want to save this list?", vbYesNo, "Save list")
  395.     If Resp = vbYes Then CmdSave_Click
  396. End If
  397. ' Save options
  398. CmdOptions_Click
  399. ' End Program
  400. End Sub
  401. Private Sub CmdInst_Click()
  402. MsgBox "JabberWin 1.0" & vbNewLine & vbNewLine & _
  403.         "JW generally follows a '...consonant-vowel-consonant-vowel...' format," & vbNewLine & _
  404.         "which is the pattern of most human language.", _
  405.         vbInformation, "How it works"
  406. End Sub
  407. Private Sub CmdNew_Click()
  408. Dim Resp As String
  409. ' If dirty prompt to save, if not name the file
  410. If Dirty Then
  411.     Resp = MsgBox("Do you want to save this list?", vbYesNo, "Save list")
  412.     If Resp = vbYes Then CmdSave_Click
  413.     FileNames = InputBox("What do you want to call this file?", "Enter Filename", "letters.dat")
  414.     If Trim(FileNames) = "" Then Exit Sub
  415.     LstCon.Clear
  416.     LstVow.Clear
  417.     Opt.WordFile = DefaultPath & "\" & FileNames
  418.     TxtFileName.Text = Opt.WordFile
  419. End If
  420. End Sub
  421. Private Sub CmdOpen_Click()
  422. Dim Resp As String, FileNam As String
  423. ' If dirty, prompt to save, if not open letters
  424. If Dirty Then
  425.     Resp = MsgBox("Do you want to save this list?", vbYesNo, "Save list")
  426.     If Resp = vbYes Then CmdSave_Click
  427.     FileNam = DialogFile(FrmJabber, 1, "Open Letters List", "", "*.DAT", DefaultPath, ".dat")
  428.     If Len(FileNam) = 0 Then Exit Sub
  429.     TxtFileName.Text = FileNam
  430.     LstCon.Clear
  431.     LstVow.Clear
  432.     LstNam.Clear
  433.     OpenLetters
  434. End If
  435. End Sub
  436. Private Sub CmdOptions_Click()
  437. ' Get free file number
  438. FileNum = FreeFile
  439. ' Get options
  440. Opt.MaxWordLen = TxtMax
  441. Opt.MinWordLen = TxtMin
  442. Opt.WordFinal = TxtEnd
  443. Opt.WordInit = TxtStart
  444. Opt.WordFile = TxtFileName
  445. For X = 0 To 2
  446.     If OptFirst(X).Value = True Then Opt.First = X
  447. ' Write options to file
  448. Open App.Path & OptFile For Output As #FileNum
  449.     Write #FileNum, Opt.MinWordLen, Opt.MaxWordLen, Opt.WordFile, Opt.First, Opt.WordInit, Opt.WordFinal
  450. Close #1
  451. End Sub
  452. Private Sub CmdSave_Click()
  453. Dim FileNum As Integer
  454. On Error GoTo ErrorHandler
  455. ' Get filename & path
  456. FileNames = DialogFile(FrmJabber, 2, "Save Letters List", "", "*.DAT", DefaultPath, ".dat")
  457. ' Get file number
  458. FileNum = FreeFile
  459. ' If nothing, exit sub
  460. If Len(FileNames) = 0 Then Exit Sub
  461. ' Write list to file
  462. Open FileNames For Output As #FileNum
  463.     Print #FileNum, "NUMBER OF CONSONANTS:"
  464.     Print #FileNum, LstCon.ListCount
  465.     Print #FileNum, "CONSONANTS:"
  466.     For X = 0 To LstCon.ListCount - 1
  467.         Print #FileNum, LstCon.List(X)
  468.     Next
  469.     Print #FileNum, "NUMBER OF VOWELS:"
  470.     Print #FileNum, LstVow.ListCount
  471.     Print #FileNum, "VOWELS:"
  472.     For X = 0 To LstVow.ListCount - 1
  473.         Print #FileNum, LstVow.List(X)
  474.     Next
  475. Close
  476. 'Change default path
  477. DefaultPath = ExtractPath(FileNames)
  478. ErrorHandler:
  479. Exit Sub
  480. End Sub
  481. Private Sub CmdSN_Click()
  482. Dim FileNum As Integer
  483. On Error GoTo ErrorHandler
  484. ' Get file name
  485. FileNames = DialogFile(FrmJabber, 2, "Save Names List", "Names.txt", "*.TXT", DefaultPath, ".txt")
  486. ' Get fiel number
  487. FileNum = FreeFile
  488. ' If nothing exit sub
  489. If Len(FileNames) = 0 Then Exit Sub
  490. ' Write names to file
  491. Open FileNames For Output As #FileNum
  492.     For X = 0 To LstNam.ListCount - 1
  493.         Print #FileNum, LstNam.List(X)
  494.     Next
  495. Close
  496. 'Change default path
  497. DefaultPath = ExtractPath(FileNames)
  498. ErrorHandler:
  499. Exit Sub
  500. End Sub
  501. Private Sub Form_Load()
  502. ' Change Form caption
  503. Me.Caption = App.Title + " " + "1.0"
  504. ' Get File number
  505. FileNum = FreeFile
  506. ' Get options from file
  507. Open App.Path & OptFile For Input As #FileNum
  508.     Input #FileNum, Opt.MinWordLen, Opt.MaxWordLen, Opt.WordFile, Opt.First, Opt.WordInit, Opt.WordFinal
  509. Close #1
  510. ' Display options
  511. TxtMax.Text = Trim(Opt.MaxWordLen)
  512. TxtMin.Text = Trim(Opt.MinWordLen)
  513. TxtEnd.Text = Trim(Opt.WordFinal)
  514. TxtStart.Text = Trim(Opt.WordInit)
  515. TxtFileName.Text = Trim(Opt.WordFile)
  516. OptFirst(Opt.First).Value = True
  517. ' Open last letters file
  518. OpenLetters
  519. ' Set default path
  520. DefaultPath = ExtractPath(Opt.WordFile)
  521. End Sub
  522. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  523. ' Save options
  524. CmdOptions_Click
  525. End Sub
  526. Private Sub LstCon_DblClick()
  527. ' Remove selected item
  528. LstCon.RemoveItem (LstCon.ListIndex)
  529. Dirty = True
  530. End Sub
  531. Private Sub LstNam_DblClick()
  532. ' Remove selected item
  533. LstNam.RemoveItem (LstNam.ListIndex)
  534. Dirty = True
  535. End Sub
  536. Private Sub LstVow_DblClick()
  537. ' Remove selected item
  538. LstVow.RemoveItem (LstVow.ListIndex)
  539. Dirty = True
  540. End Sub
  541. Private Sub OptFirst_Click(Index As Integer)
  542. Opt.First = Index
  543. End Sub
  544. Private Sub TxtAR_GotFocus()
  545. ' Select entire textbox
  546. TxtAR.SelStart = 0
  547. TxtAR.SelLength = Len(TxtAR.Text)
  548. End Sub
  549. Private Sub TxtEnd_GotFocus()
  550. ' Select entire textbox
  551. TxtEnd.SelStart = 0
  552. TxtEnd.SelLength = Len(TxtEnd.Text)
  553. End Sub
  554. Private Sub TxtMax_GotFocus()
  555. ' Select entire textbox
  556. TxtMax.SelStart = 0
  557. TxtMax.SelLength = Len(TxtMax.Text)
  558. End Sub
  559. Private Sub TxtMin_GotFocus()
  560. ' Select entire textbox
  561. TxtMin.SelStart = 0
  562. TxtMin.SelLength = Len(TxtMin.Text)
  563. End Sub
  564. Private Sub TxtStart_GotFocus()
  565. ' Select entire textbox
  566. TxtStart.SelStart = 0
  567. TxtStart.SelLength = Len(TxtStart.Text)
  568. End Sub
  569.